package class2015;


//These are jarfile or API
import java.util.concurrent.TimeUnit;

import org.junit.*;

import static org.junit.Assert.*;

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
//update classname with Search and remove unused import
//We can only have one class file in one File
//WebDriver is a Browser or API 
//blue words are changeable
public class Search {
  private WebDriver driver;
  private String baseUrl;
  private StringBuffer verificationErrors = new StringBuffer();

  @Before
  public void setUp() throws Exception {
    driver = new FirefoxDriver();
    baseUrl = "http://www.ad-mela.com";
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
  }

  @Test
  public void testUntitled() throws Exception {
	  driver.get(baseUrl + "/Default.asp");
	  String moreWords;
	  moreWords="bride";
	  //take mysearch into a variable to make the script short and use it
	  WebElement mySearch;
	 mySearch =  driver.findElement(By.name("SearchWord"));
     mySearch.clear();
     mySearch.sendKeys("groom "+ moreWords);
     WebElement myButton;
     myButton=driver.findElement(By.name("searchbutton"));
     myButton.click();
    		 
     	        
  }

  @After
  public void tearDown() throws Exception {
    //quit is for closing window
	  //driver.quit();
    String verificationErrorString = verificationErrors.toString();
    if (!"".equals(verificationErrorString)) {
      fail(verificationErrorString);
    }
  }
}

